<template>
  <ex-dialog
    width="600px"
    class="ex-diolog"
    title="添加盲盒奖品数量"
    :visible="visible"
    @closeDialog="handleClose"
  >	
		<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="140px" class="demo-ruleForm">
      <el-form-item label="添加奖品数量" prop="amount">
				<el-input type="text" v-model="ruleForm.amount" autocomplete="off" placeholder="请输入奖品数量"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="submitForm('ruleForm')">确认</el-button>
				<el-button @click="handleClose('ruleForm')">取消</el-button>
			</el-form-item>
		</el-form>
  </ex-dialog>
</template>
<script>
// components
import Loading from '@/components/Loading/index'
// api
import {
  addBoxPrizeNum
} from '@/api/blindBox/boxSet'

export default {
  components: {
    Loading
  },
  props: {
    visible: Boolean,
    id: String,
  },
  data() {
    
    return {
			ruleForm: {
				amount: '',
				id: '',
			},
			rules: {
        amount: [
          { required: true,message: '请输入数量',trigger: 'blur' }
        ],
      }
    }
  },
  computed: {
   
  },
  created() {
    console.log('id',this.id )
    this.ruleForm.id = this.id
  },
  methods: {
    //新建子账号
    submitForm(formName) {
      console.log('formName',formName)
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var data = {
          ...this.ruleForm
          }
          addBoxPrizeNum(data).then(res => {
            this.handleSuccess("新增成功")
          }).finally(() => {
            this.loading = false
          })
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    
		//取消
    handleClose(formName) {
      this.$emit('update:visible', false)
			// this.$refs[formName].resetFields();
    },
		//确认
		handleConfirm(){
			this.$emit('success', '你好')
		},
    handleSuccess(msg) {
      if (msg === '已拒绝') {
        var type = 'error'
      } else {
        var type = 'success'
      }
      this.$message({
        message: msg,
        type: type,
        duration: 1500,
        onClose: () => {
          this.handleClose()
          this.$emit('success')
        }
      })
    },
  }
}
</script>
<style lang="scss" scoped>
.ex-diolog {
  ::v-deep .ex--dialog--footer {
    border: none !important;
		padding: 0 !important;
  }
	::v-deep .ex--dialog--main {
    padding: 10px 20px !important;
  }
}
::v-deep .avatar-uploader2 .el-upload {
  width: 100% !important;
}

.avatar-uploader2 {
  width: 130px;
  height: 130px;
  text-align: center;
  line-height: 130px;
  background-color: #fbfdff;
  border: 1px dashed #c0ccda;
}

.banner_img {
  width: 130px;
  height: 130px;
}
</style>